﻿using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Electronic_work_order.Model
{
    public static class ModelBuilderExtensions
    {
        public static void Seed(this ModelBuilder modelBuilder)
        {
            //角色表数据添加
            modelBuilder.Entity<UserRole>().HasData(
                //最高级别权限
                new UserRole { RoleID = 1, Parent_RoleID = 0, RoleName = "经理", CreateTime = DateTime.Now },
                new UserRole { RoleID = 2, Parent_RoleID = 1, RoleName = "主管", CreateTime = DateTime.Now },     
                new UserRole { RoleID = 3, Parent_RoleID = 2, RoleName = "普通员工", CreateTime = DateTime.Now }           
                );

            //权限状态表
            modelBuilder.Entity<PermissionState>().HasData(
               new PermissionState { PermissionStateID = 1, PermissionStateName = "启用" },
               new PermissionState { PermissionStateID = 2, PermissionStateName = "禁用" }
               );

            //权限表
            modelBuilder.Entity<Permission>().HasData(
                new Permission { PermissionID = 1, PermissionName = "系统管理员", Comments = "最高级别的权限，可以访问所有的数据", PermissionStateID = 1 },
                new Permission { PermissionID = 2, PermissionName = "超级管理员", Comments = "第二级别权限，可以访问第二子节点下的数据", PermissionStateID = 1 },
                new Permission { PermissionID = 3, PermissionName = "普通管理员", Comments = "第三级别权限，只能访问自己页面", PermissionStateID = 1 }
            );

            //添加角色+权限表
            modelBuilder.Entity<Role_Permission>().HasData(
                //最高级别访问权限
                        new Role_Permission { Role_Permission_ID = 1, PermissionID = 1, RoleID = 1}, 
                  //第二级别的访问权限
                        new Role_Permission { Role_Permission_ID = 2, PermissionID = 2, RoleID = 2},
                        //第三访问的权限            
                        new Role_Permission { Role_Permission_ID = 3, PermissionID = 3, RoleID = 3 }
                );

            //添加组织表
            modelBuilder.Entity<Organization>().HasData(

                new Organization { OrganizationID=1, OrganizationName= "人事部",  Update_date=DateTime.Now},
                new Organization { OrganizationID = 2, OrganizationName = "行政部",Update_date = DateTime.Now },
                new Organization { OrganizationID = 3, OrganizationName = "客户部", Update_date = DateTime.Now },
                new Organization { OrganizationID = 4, OrganizationName = "采购部", Update_date = DateTime.Now }
                ////最高级别
                //new Organization {OrganizationID=1,OrganizationName="OA办公总部",ParentId=0, Grade="1"},
                //    //部门
                //new Organization {OrganizationID=2, OrganizationName = "人事部", ParentId = 1, Update_date= DateTime.Now, Grade = "2" },
                //new Organization { OrganizationID = 3, OrganizationName = "行政部", ParentId = 1, Update_date = DateTime.Now, Grade = "2" },
                //new Organization { OrganizationID = 4, OrganizationName = "客户部",  ParentId = 1, Update_date = DateTime.Now, Grade = "2" },
                //new Organization { OrganizationID = 5, OrganizationName = "采购部",  ParentId = 1, Update_date = DateTime.Now, Grade = "2" },
                //     //职位
                // new Organization { OrganizationID = 6, OrganizationName = "人力资源经理",  ParentId = 2, Update_date = DateTime.Now, Grade = "3" },           
                // new Organization { OrganizationID = 7, OrganizationName = "人力资源总监",  ParentId = 6, Update_date = DateTime.Now, Grade = "3" },
                // new Organization { OrganizationID = 8, OrganizationName = "招聘主管",  ParentId = 7, Update_date = DateTime.Now, Grade = "3" },
                // new Organization { OrganizationID = 9, OrganizationName = "人事部普通员工", ParentId = 8, Update_date = DateTime.Now, Grade = "3" },

                //new Organization { OrganizationID = 10, OrganizationName = "行政部经理",  ParentId = 3, Update_date = DateTime.Now, Grade = "3" },
                //new Organization { OrganizationID = 11, OrganizationName = "行政部主管", ParentId = 10, Update_date = DateTime.Now, Grade = "3" },
                //new Organization { OrganizationID = 12, OrganizationName = "行政管理员", ParentId =11, Update_date = DateTime.Now, Grade = "3" },
                // new Organization { OrganizationID = 13, OrganizationName = "行政部普通员工", ParentId = 12, Update_date = DateTime.Now, Grade = "3" },

                //new Organization { OrganizationID =14, OrganizationName = "客户经理", ParentId = 4, Update_date = DateTime.Now, Grade = "3" },
                //new Organization { OrganizationID = 15, OrganizationName = "客户主管", ParentId = 14, Update_date = DateTime.Now, Grade = "3" }, 
                // new Organization { OrganizationID = 16, OrganizationName = "客户部普通员工", ParentId = 15, Update_date = DateTime.Now, Grade = "3" },

                // new Organization { OrganizationID = 17, OrganizationName = "采购总经理",  ParentId = 5, Update_date = DateTime.Now, Grade = "3" },
                //new Organization { OrganizationID = 18, OrganizationName = "采购主管",  ParentId = 17, Update_date = DateTime.Now, Grade = "3" },
                // new Organization { OrganizationID = 19, OrganizationName = "普通采购员", ParentId = 18, Update_date = DateTime.Now, Grade = "3" }
            
                 );
            //添加职位表
            modelBuilder.Entity<Position>().HasData(
                //人事部
                new Position { PositionID = 1, ParentID = 1, PositionName = "人事部经理",Grade=0 },
                new Position { PositionID = 2, ParentID = 1, PositionName = "人事部主管",Grade=1 },
                new Position { PositionID = 3, ParentID = 1, PositionName = "人事部职员",Grade=2 },
                 //行政部
                new Position { PositionID = 4, ParentID = 2, PositionName = "行政部经理", Grade = 0 },
                new Position { PositionID = 5, ParentID = 2, PositionName = "行政部主管", Grade = 4 },
                new Position { PositionID = 6, ParentID = 2, PositionName = "行政部职员", Grade = 5 },
                //客户部
                new Position { PositionID = 7, ParentID = 3, PositionName = "客户部经理", Grade = 0 },
                new Position { PositionID = 8, ParentID = 3, PositionName = "客户部主管", Grade =7 },
                new Position { PositionID = 9, ParentID = 3, PositionName = "客户部职员", Grade =8 },
                //采购部
                new Position { PositionID = 10, ParentID = 4, PositionName = "采购部经理", Grade =0 },
                new Position { PositionID = 11, ParentID = 4, PositionName = "采购部主管", Grade = 10 },
                new Position { PositionID = 12, ParentID = 4, PositionName = "采购部职员", Grade = 11 }
                );
            //添加人员数据
            modelBuilder.Entity<Users>().HasData(
                new Users { UsersID = 1 , UsersName="周艳玲",UsersPwd="123456",UsersSex="女",UsersPhone="13728491578",UsersEmail="abc1@qq.com",PositionID=1,EntryTime=DateTime.Now,QuitTime="",RoleID=1, Remarks="",StateID = 1 },
                new Users { UsersID =2, UsersName = "雷晴晴", UsersPwd = "123456", UsersSex = "女", UsersPhone = "13728491579", UsersEmail = "abc2@qq.com", PositionID = 2,  EntryTime = DateTime.Now, QuitTime = "",RoleID=2, Remarks = "", StateID = 1 },
                new Users { UsersID = 3, UsersName = "陈臣", UsersPwd = "123456", UsersSex = "男", UsersPhone = "13728491576", UsersEmail = "abc3@qq.com", PositionID = 3,  EntryTime = DateTime.Now, QuitTime = "", RoleID=3, Remarks = "", StateID = 1 },
                new Users { UsersID = 4, UsersName = "杨思航", UsersPwd = "123456", UsersSex = "女", UsersPhone = "13728491575", UsersEmail = "abc4@qq.com", PositionID = 4, EntryTime = DateTime.Now, QuitTime = "", RoleID=1, Remarks = "", StateID = 1 }
                ) ;
            //给人员状态表添加数据
            modelBuilder.Entity<UserState>().HasData(
                new UserState {StateID=1,StateName="在职" },
                new UserState { StateID = 2, StateName = "离职" }    
                );
            //事假,病假,婚假,产假,丧假,年休假,补休假,其他 
            modelBuilder.Entity<Leave_Type>().HasData(
                 new Leave_Type { Leave_Type_ID=1,Leave_Type_Name= "事假" },
                 new Leave_Type { Leave_Type_ID = 2, Leave_Type_Name = "病假" },
                 new Leave_Type { Leave_Type_ID = 3, Leave_Type_Name = "婚假" }, 
                 new Leave_Type { Leave_Type_ID = 4, Leave_Type_Name = "产假" },
                 new Leave_Type { Leave_Type_ID = 5, Leave_Type_Name = "丧假" },
                 new Leave_Type { Leave_Type_ID = 6, Leave_Type_Name = "年休假" },
                 new Leave_Type { Leave_Type_ID = 7, Leave_Type_Name = "补休假" },
                 new Leave_Type { Leave_Type_ID = 8, Leave_Type_Name = "其他" }
                );

            modelBuilder.Entity<Process_application_State>().HasData(
                 new Process_application_State { Process_State_ID = 1, Process_State_Name = "正在起草" },
                 new Process_application_State { Process_State_ID = 2, Process_State_Name = "申请中" },
                 new Process_application_State { Process_State_ID = 3, Process_State_Name = "第一步审批成功" },
                 new Process_application_State { Process_State_ID = 4, Process_State_Name = "第二步审批成功" },
                 new Process_application_State { Process_State_ID = 5, Process_State_Name = "未通过" },
                 new Process_application_State { Process_State_ID = 6, Process_State_Name = "已完成" }
                );
            //人员请假表（请假登记表）
            modelBuilder.Entity<LeaveForm>().HasData(
                new LeaveForm {
                    LeaveID=1,                  
                    Leave_Type_ID = 1,
                    Sex = "男",                
                    AuditTime="1天",
                    LeaveMatter = "回家陪父母",             
                        }
                    );
            //采购物品申请表
            modelBuilder.Entity<Purchase_goods>().HasData(
                new Purchase_goods
                {
                    Purchase_ID = 1,
           
                    Purchase_goods_Name = "激光笔",   
                 
                    Unit_Price = 1.2,
                    GoodCount = 100,
              
                    Subtotal = 120
                }) ;
            //费用申请表
            modelBuilder.Entity<Expense_reimbursement>().HasData(
                 new Expense_reimbursement { erId = 1, erName = "雷晴晴", erTime = DateTime.Now, OrganizationID = 1, PositionID = 2, erTId = 2, erFY = 200, erBZ = "出去帮老板做事", Process_State_ID=1, Aid = 5 },
                  new Expense_reimbursement { erId = 2, erName = "雷晴晴", erTime = DateTime.Now, OrganizationID = 1, PositionID = 2, erTId = 3, erFY = 200, erBZ = "出去帮老板买饭花了200", Process_State_ID = 1, Aid = 5}
                );

            //费用申请状态表
            modelBuilder.Entity<Expense_reimbursement_Type>().HasData(
                  new Expense_reimbursement_Type { erTId = 1, erTName = "电话费" },
                  new Expense_reimbursement_Type { erTId = 2, erTName = "交通费" },
                  new Expense_reimbursement_Type { erTId = 3, erTName = "餐饮费" },
                  new Expense_reimbursement_Type { erTId = 4, erTName = "其他" }
                );


            //差旅费申请表
            modelBuilder.Entity<travel_on_business>().HasData(
                new travel_on_business { tbId = 1, tbName = "雷晴晴", tbTime = DateTime.Now, tbSY = "出差办事", 
                    OrganizationID = 1, PositionID = 2, tbBeginAddress = "湖南长沙", tbEndAddress = "广东广州",
                    tbBeginTime = DateTime.Now, tbEndTime = DateTime.Now, tbJTF = 100,
                    tbCYF = 500, tbZSF = 1000, tbSum = 1600, tbZB = "报销", Process_State_ID = 2, Aid = 6}
                );

            //套餐表
            modelBuilder.Entity<Set_meal>().HasData(
                new Set_meal { MealID = 1, MealName = "单人套餐" },
                new Set_meal { MealID = 2, MealName = "双人套餐" },
                new Set_meal { MealID = 3, MealName = "清爽套餐" },
                new Set_meal { MealID = 4, MealName = "爆椒套餐" },
                new Set_meal { MealID = 5, MealName = "清水套餐" },
                new Set_meal { MealID = 6, MealName = "爱吃不吃套餐" }
                );

            //订餐状态表
            modelBuilder.Entity<OrderState>().HasData(
                new OrderState { OrderStateID = 1, OrderStateName = "午餐" },
                new OrderState { OrderStateID = 2, OrderStateName = "晚餐" }
                );

            //订餐申请表
            modelBuilder.Entity<Ordering>().HasData(
                new Ordering { OrderID = 1, Otime = DateTime.Now, OrderStateID = 1,
                    OrganizationID = 1, OrName = "杨思航", closing_time = DateTime.Now, 
                    MealID = 1, Process_State_ID = 1, Aid = 4 }
                );

            //人员需求表
            modelBuilder.Entity<Demand>().HasData(
               new Demand { DemandID = 1, Stime = DateTime.Now, Rtime = DateTime.Now, DeName = "杨思航",
                   OrganizationID = 1, PositionID = 1, num = 20, cause = "缺人", need = "是个人就行",
                   Process_State_ID = 2, Aid = 3}
                );

            //所有申请类型表（如人员需求申请，请假申请）
            modelBuilder.Entity<application>().HasData(
                new application { Aid=1,Aname="请假申请"},
                new application { Aid = 2, Aname = "采购申请" },
                new application { Aid = 3, Aname = "人员需求申请" },
                new application { Aid = 4, Aname = "订餐申请" },
                new application { Aid = 5, Aname = "报销费用申请" },
                new application { Aid = 6, Aname = "差旅费用申请" }

                );
            //代办合集表
            modelBuilder.Entity<commission>().HasData(
                new commission { Agency_ID = "2021042114", ApplicationName = "陈臣", OrganizationId = 1, Aid = 1, Manager_id = 1, Director_Id = 2, Process_State_ID = 2, CreateTime = DateTime.Now },
                 new commission { Agency_ID = "2021042115", ApplicationName = "陈臣", OrganizationId = 1, Aid = 2, Manager_id = 1, Director_Id = 2, Process_State_ID = 2, CreateTime = DateTime.Now }
                  //new commission { Agency_ID = "2021042116" } ,
                  //new commission { Agency_ID = "2021042117" } ,
                  //new commission { Agency_ID = "2021042118" },
                  // new commission { Agency_ID = "2021042119" }
                );
        }
    }
}
